package jnpf.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jnpf.base.service.BillRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.base.UserInfo;
import jnpf.base.vo.DownloadVO;
import jnpf.config.ConfigValueUtil;
import jnpf.exception.DataException;
import jnpf.model.whu_shock_event.Whu_shock_eventListVO;
import jnpf.service.Whu_shock_eventService;
import org.springframework.transaction.annotation.Transactional;
import jnpf.base.entity.ProvinceEntity;
import jnpf.model.whu_grey_list.*;
import jnpf.model.whu_grey_list.Whu_grey_listPagination;
import jnpf.model.whu_grey_list.Whu_grey_listCrForm;
import jnpf.model.whu_grey_list.Whu_grey_listInfoVO;
import jnpf.model.whu_grey_list.Whu_grey_listListVO;
import jnpf.model.whu_grey_list.Whu_grey_listUpForm;
import jnpf.entity.*;
import jnpf.base.service.ProvinceService;
import jnpf.util.*;
import jnpf.base.util.*;
import jnpf.base.vo.ListVO;
import jnpf.util.context.SpringContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jnpf.entity.Whu_grey_listEntity;
import jnpf.service.Whu_grey_listService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;


/**
 *
 * whu_grey_list
 * @版本： V3.2.0
 * @版权： 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * @作者： JNPF开发平台组
 * @日期： 2024-09-26
 */
@Slf4j
@RestController
@Api(tags = "whu_grey_list" , value = "example")
@RequestMapping("/api/example/Whu_grey_list")
public class Whu_grey_listController {

    @Autowired
    private DynDicUtil dynDicUtil;
    @Autowired
    private GeneraterSwapUtil generaterSwapUtil;
    @Autowired
    private UserProvider userProvider;

    @Autowired
    private Whu_grey_listService whu_grey_listService;

    @Autowired
    private Whu_shock_eventService whu_shock_eventService;

    /**
     * 列表
     *
     * @param
     * @return
     */
	@PostMapping("/getList")
    public ActionResult qrcgList() throws IOException{
        QueryWrapper<Whu_shock_eventEntity> queryWrapper = new QueryWrapper<>();
        //确认状态查询
        queryWrapper.lambda().eq(Whu_shock_eventEntity::getState,"28c6b86397854396af54da047816b2d3");
        //排序
        queryWrapper.lambda().orderByDesc(Whu_shock_eventEntity::getTime);

        List<Whu_shock_eventEntity> list= whu_shock_eventService.list(queryWrapper);

        List<Whu_shock_eventListVO> listVO=JsonUtil.getJsonToList(list,Whu_shock_eventListVO.class);
        return ActionResult.success(listVO);
    }


    /**
     * 创建
     *
     * @param whu_grey_listCrForm
     * @return
     */
    @PostMapping
    @Transactional
    public ActionResult create(@RequestBody @Valid Whu_grey_listCrForm whu_grey_listCrForm) throws DataException {
        String mainId =RandomUtil.uuId();
        UserInfo userInfo=userProvider.get();
        Whu_grey_listEntity entity = JsonUtil.getJsonToBean(whu_grey_listCrForm, Whu_grey_listEntity.class);
				entity.setId(mainId);
                whu_grey_listService.save(entity);


        return ActionResult.success("创建成功");
}




    /**
    * 信息
    *
    * @param id
    * @return
    */
    @GetMapping("/{id}")
    public ActionResult<Whu_grey_listInfoVO> info(@PathVariable("id") String id){
        Whu_grey_listEntity entity= whu_grey_listService.getInfo(id);
        Whu_grey_listInfoVO vo=JsonUtil.getJsonToBean(entity, Whu_grey_listInfoVO.class);

        return ActionResult.success(vo);
    }





   /**
    * 更新
    *
    * @param id
    * @return
    */
    @PutMapping("/{id}")
    @Transactional
    public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid Whu_grey_listUpForm whu_grey_listUpForm) throws DataException {
        UserInfo userInfo=userProvider.get();
        Whu_grey_listEntity entity= whu_grey_listService.getInfo(id);
        if(entity!=null){
            Whu_grey_listEntity subentity=JsonUtil.getJsonToBean(whu_grey_listUpForm, Whu_grey_listEntity.class);
            whu_grey_listService.update(id, subentity);
        return ActionResult.success("更新成功");
        }else{
            return ActionResult.fail("更新失败，数据不存在");
        }
    }

   /**
    * 删除
    *
    * @param id
    * @return
    */
    @DeleteMapping("/{id}")
    @Transactional
    public ActionResult delete(@PathVariable("id") String id){
        Whu_grey_listEntity entity= whu_grey_listService.getInfo(id);
        if(entity!=null){
            whu_grey_listService.delete(entity);

        }
        return ActionResult.success("删除成功");
    }


}
